Preventing Image Hot Linking and Stealing |
||||
Believe it or not there are some people out there who, rather than developing their own content they prefer to steal yours. This normally is a breach of copyright laws and is punishable but as you can guess, it is very hard to prove. | ||||
So how can you protect your website content from thieves? Well sadly, it is impossible to stop, however you can help slow then down. So why slow them down? Well this acts as a good deterrent also many thieves will steal your images by hot linking to them. |
||||
|
||||
Preventing Hot Linking with .htaccess |
||||
We will be using the power of the .htaccess file to achieve our goal. With this amazing piece of code below, we can prevent people hot linking to our images while still allowing others to view them. Remember if you already have a .htaccess file then you will need to add only a few lines, these lines are shown in more detail | ||||
|
||||
Line 1 is always necessary in your .htaccess file, it informs Apache (the programme that acts as the web server) to follow any links it finds Line 2 is just a description line of what the code is Line 3 turns on the Rewrite Engine, this is what does the magic we need Line 4 This is the first RewriteCond line (Rewrite Condition if you are wondering) this line allows direct requests to the file. Line 5 This is the matching condition, this line means if the referrer sent by the website browser is Paramiliar.com then allow it access to the file requested. Line 6 This is the line that stops others hot linking your files, this line tells apache that if none of the rules are met then they are not allowed to view any files that end with .gif, .jpg, .png or .jpeg and instead shows them the file hotlink.jpg which you can set to display a friendly message. |
||||
What if I already have a .htaccess file? |
||||
Well if you already have a .htaccess file then there are certain lines you need and some you don’t. First off the very first line of your .htaccess file should always have the Options+FollowSymlinks After you have that on the first line all you need to do is use lines 3,4,5 and 6 in any location in your file so long as they are in the order shown in the code example. So lets say you have a website called myaccess.com and you want to use this script, but you also want to give access to myaccess.co.uk to the images, then your .htaccess file would look something like this. |
||||
|
||||
And that’s all there is to it, I hope you have enjoyed this article as always if you have any questions simply leave a comment or drop us an email by using the contact us page. | ||||
Kind Regards |